CSharpTest.Net
Contains Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : Contains Method

item
The object to locate in the ICollection.

Glossary Item Box

Determines whether the ICollection contains a specific value pair.

Syntax

Visual Basic (Declaration) 
Public Function Contains( _
   ByVal item As T _
) As Boolean
C# 
public bool Contains( 
   T item
)

Parameters

item
The object to locate in the ICollection.

Return Value

true if item is found in the ICollection; otherwise, false.

Example

Library/Library.Test/TestBTreeList.cs

C#Copy Code
BTreeList<int> test = new BTreeList<int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
IList<int> list = test;
for (int i = 10; i < 1000; i++)
    test.Add(i);

for(int i=900; i >0; i-=100)
{
    Assert.IsTrue(test.Contains(i));
    Assert.AreEqual(i, list.IndexOf(i));
    list.RemoveAt(i);
    Assert.IsFalse(test.Contains(i));
    Assert.AreEqual(-1, list.IndexOf(i));
    Assert.AreEqual(i + 1, list[i]);
}

list.RemoveAt(0);
list.RemoveAt(1);
list.RemoveAt(2);
Assert.AreEqual(1, list[0]);
Assert.AreEqual(3, list[1]);
Assert.AreEqual(5, list[2]);

Assert.AreEqual(1000 - 12, list.Count);
VB.NETCopy Code
Dim test As New BTreeList(Of Integer)(New Integer() {0, 1, 2, 3, 4, 5, _
    6, 7, 8, 9})
Dim list As IList(Of Integer) = test
Dim i As Integer = 10
While i < 1000
    test.Add(i)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim i As Integer = 900
While i > 0
    Assert.IsTrue(test.Contains(i))
    Assert.AreEqual(i, list.IndexOf(i))
    list.RemoveAt(i)
    Assert.IsFalse(test.Contains(i))
    Assert.AreEqual(-1, list.IndexOf(i))
    Assert.AreEqual(i + 1, list(i))
    i -= 100
End While

list.RemoveAt(0)
list.RemoveAt(1)
list.RemoveAt(2)
Assert.AreEqual(1, list(0))
Assert.AreEqual(3, list(1))
Assert.AreEqual(5, list(2))

Assert.AreEqual(1000 - 12, list.Count)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys